<?php
$count = 0;
function out($left, $right)
{
	$size = strlen($left)+strlen($right);
	$middle = '';
	for($i = 0; $i < 100 - $size; ++$i, $middle .= ' ');
	echo  $left, $middle, $right;	
}
function parse_dir($dirname)
{
	global $count;	
	$dir = opendir($dirname);
	while ($file = readdir($dir))
	{		if (is_dir($dirname . $file) && $file !== '.' && $file !== '..' && $file !== '.svn')
		{
			parse_dir($dirname . $file . '/');
		}
		
		if (is_file($dirname . $file) && preg_match('/(.*)\.(cpp|h)/', $file))
		{		
			$count += $d = count(file($dirname . $file));
			out("$dirname$file: ", "$d line" . (($d>1) ? "s" : '') ."\n");
			
		}
		
	}
	closedir($dir);
}
parse_dir('E:/MyDocs/MyProgr/ultramaze/src/');
out("Total: ", "$count line". (($count>1)?"s":'') ."\n");
?>